package com.dxl.rest;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Description: 获取配置文件的类
 *
 * @author: Yingyu Wei
 * <p>File Created at 2021/4/4</p>
 */
@RestController
public class ValueController {
    @Value("${server.port}")
    private Integer port;
    @Value("${server.servlet.context-path}")
    private String path;
    @Value("${alipay.appid}")
    private String appid;
    @Value("${alipay.email}")
    private String email;
    @Value("${user.names}")
    private String user_arr;
    @Value("${user.friends}")
    private String user_map;

    @Value("${user.names}") // zhangsan,xiaoxie,lisi,xiaoguo
    private String[] names;
    @Value("${user.friends}") // zhangsan1,xiaoxie1,lisi1,xiaoguo1
    private List<String> friends;

    @RequestMapping(value = "/value",method = RequestMethod.GET)
    public String getValue(){

        System.out.println(port);
        System.out.println(path);
        System.out.println(appid);
        System.out.println(email);
        System.out.println(user_arr);
        System.out.println(user_map);
        return null;
    }
    @GetMapping("/value1")
    public String getValues(){
        for (String name : names) {
            System.out.println(name);
        }
        return appid+"==="+email + "===" + friends;
    }
/*小结：用数组、List接，都是可以的。*/
}
